abstract class Shape {
    public abstract double area();

    public abstract double perimeter();
}
class Circle extends Shape {

    private double diameter;

    public Circle(double diameter) {
        this.diameter = diameter;
    }

    @Override
    public double area() {
        return Math.PI * Math.pow(diameter / 2, 2);
    }
 
    @Override
    public double perimeter() {
        return Math.PI * diameter;
    }
 
}
class Rectangle extends Shape {
 
    private double length;
    private double width;

    public Rectangle(double width,double length) {
        this.width = width;
        this.length=length;
    }

    @Override
    public double area() {
        return length * width;
    }
 
    @Override
    public double perimeter() {
        return 2 * (length+width);
    }
}

class Triangle extends Shape{
    private double a,b,c;

    public Triangle(double a, double b, double c) {
        this.a = a;
        this.b = b;
        this.c = c;
    }

    @Override
    public double area() {
        double s = 0, p;
        if (a + b > c && b + c > a && c + a > b) {
            p = (a + b + c) / 2;
            s = Math.sqrt(p * (p - a) * (p - b) * (p - c));
        } else {
            s = -1;
        }
        return s;
    }

    @Override
    public double perimeter() {
        return a+b+c;
    }
}
 
public class Num_5 {
    public static void main(String[] args) {
 
        Rectangle rec = new Rectangle(5,10);;
        double rec_area = rec.area();
        double rec_perimeter = rec.perimeter();
        System.out.println("矩形的面积："+rec_area+"，周长"+rec_perimeter);
 
        Circle cir = new Circle(10);
        double cir_area = cir.area();
        double cir_perimeter = cir.perimeter();
        System.out.println("圆形的面积："+cir_area+"，周长"+cir_perimeter);

        Triangle tri =new Triangle(3,4,5);
        double tri_area= tri.area();
        double tri_perimeter=tri.perimeter();
        System.out.println("三角形的面积："+tri_area+"，周长"+tri_perimeter);
    }
 
}